/*
 * Copyright 2010-2012 Susanta Tewari. <freecode4susant@users.sourceforge.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package coalescent.cef.command.listener;

import cef.command.Command;
import cef.command.listener.CommandOutputEvent;
import cef.command.listener.CommandOutputListener;
import cef.command.listener.CommandOutputListenerException;
import cef.command.listener.CommandPrintWriter;

import coalescent.cef.command.CheckPhylogenyCommand;

/**
 * A command listener for {@code CheckPhylogenyCommand}.
 *
 * @author Susanta Tewari
 * @version 1.0 Jan 17, 2011
 */
public class CheckPhylogenyCommandListener extends CommandPrintWriter {

    /**
     * Method description
     *
     *
     * @param cmdEvent
     *
     * @throws CommandOutputListenerException
     */
    @Override
    public void receivedEventImpl(CommandOutputEvent cmdEvent)
            throws CommandOutputListenerException {

        if (cmdEvent.getSource() instanceof CheckPhylogenyCommand) {

            CheckPhylogenyCommand command = (CheckPhylogenyCommand) cmdEvent.getSource();

            getPrintWriter().println("Phylogeny Check: " + command.isPhylogeny());
            getPrintWriter().flush();
        }
    }

    /**
     * Method description
     *
     *
     * @return
     */
    @Override
    public Class<? extends Command> getTargetCommandClass() {
        return CheckPhylogenyCommand.class;
    }

    /**
     * Method description
     *
     *
     * @return
     */
    @Override
    public CommandOutputListener newInstance() {
        return new CheckPhylogenyCommandListener();
    }
}
